/**
 * 
 */
package com.fox.webapp.web.admin;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fox.webapp.domain.SystemSetting;
import com.fox.webapp.service.ISystemSettingService;
import com.fox.webapp.utils.Constant;

/**
 * @author yockii
 *
 */
@Controller
@RequestMapping("admin/systemSetting")
public class SystemSettingAdminController {

	@Autowired
	private ISystemSettingService systemSettingService;
	
	@RequestMapping(value = {"", "index", "index.html"}, method = RequestMethod.GET)
	public String sysSettingPage(Model model){
		List<SystemSetting> ssList = systemSettingService.getAllSettings();
		model.addAttribute("ssList", ssList);
		return "admin/settings/system";
	}
	
	@RequestMapping(value = {"", "index", "index.html"}, method = RequestMethod.POST)
	@ResponseBody
	public int updateSetting(SystemSetting setting){
		boolean success = systemSettingService.updateSetting(setting);
		return success?Constant.RESULT_SUCCESS:Constant.RESULT_FAILED;
	}
}
